package com.gaara.ddp;

import org.loon.framework.android.game.action.sprite.Sprite;
import org.loon.framework.android.game.action.sprite.SpriteImage;
import org.loon.framework.android.game.core.LSystem;
import org.loon.framework.android.game.core.graphics.LImage;
import org.loon.framework.android.game.core.graphics.Screen;
import org.loon.framework.android.game.core.graphics.Touch;
import org.loon.framework.android.game.core.graphics.device.LGraphics;
import org.loon.framework.android.game.core.graphics.window.LButton;
import org.loon.framework.android.game.core.graphics.window.actor.Actor;
import org.loon.framework.android.game.core.graphics.window.actor.Layer;
import org.loon.framework.android.game.core.timer.LTimerContext;
import org.loon.framework.android.game.utils.GraphicsUtils;

public class StartScreen extends Screen {
	LButton startBtn;
	Boolean init = false;
	Actor snow;
	int angle = -360;
	float alphas = 0;
	float adds = 0.01F;

	@Override
	public void onLoaded() {
		//设置背景
		setBackground("res/startBack.png",false);
	}

	@Override
	public void alter(LTimerContext timer) {
		if(!init){
			init = true;
			//设置初始化按钮
			startBtn = new LButton("res/startBtn.png", 196, 54) {
				@Override
				public void doClick() {
	//				setScreen(new TitleScreen());
					//		playAssetsMusic("res/sound/startgame.mp3",false);
				}
			};
			startBtn.setLocation((LSystem.MAX_SCREEN_WIDTH-startBtn.getWidth())/2,340);
			startBtn.setEnabled(true);
			add(startBtn);

			Layer layer = new Layer(LSystem.MAX_SCREEN_WIDTH, LSystem.MAX_SCREEN_HEIGHT);
			snow = new Actor("res/titlesnow.png",100,100);
			layer.addObject(snow);
			add(layer);

		}
		if(init){
			angle +=10;
			if(angle >= 360){
				angle = -360;
			}

			snow.rotateTo(angle);

			alphas = alphas+adds;
			if(alphas <= 0.2){
				adds = 0.01F;
			}
			else if (alphas >= 1){
				adds = -0.01F;
			}
	

			snow.setAlpha(alphas);
			System.out.println(adds);
			System.out.println(alphas);
		}

	}




	@Override
	public void draw(LGraphics arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onTouchDown(Touch arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onTouchMove(Touch arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onTouchUp(Touch arg0) {
		// TODO Auto-generated method stub

	}

}
